﻿Module some_function
    Function get_2ma_from_3ma_array(arrIndex As Integer, arr3(,) As Integer) As String()
        Dim arr() As String, tmp As String = "", tmpS As String = "", t As Integer = 0
        For i = 0 To 2
            For j = i + 1 To 2
                tmp = arr3(arrIndex, i) & arr3(arrIndex, j)
                If tmpS.IndexOf(tmp) < 0 Then
                    ReDim Preserve arr(t)
                    tmpS = tmpS & tmp & " "
                    arr(t) = tmp
                    t = t + 1
                End If
            Next
        Next

        Return arr
    End Function
    Function get_2ma_from_3ma_string(arrIndex As Integer, arr3(,) As Integer) As String
        Dim tmpS As String = "", tmp As String = ""
        For i = 0 To 2
            For j = i + 1 To 2
                tmp = arr3(arrIndex, i) & arr3(arrIndex, j)
                If tmpS.IndexOf(tmp) < 0 Then
                    tmpS = tmpS & tmp & " "
                End If
            Next
        Next

        Return tmpS.Trim
    End Function
    Function change_array_zhixuan_to_zuxuan(arr(,) As Integer) As Integer(,)
        Dim arrX() As Integer, arrOut(,) As Integer
        Dim u As Integer = UBound(arr, 1)
        Dim u2 As Integer = UBound(arr, 2)
        ReDim arrX(0 To u2)
        ReDim arrOut(0 To u, 0 To u2)
        For i = 0 To u
            For j = 0 To u2
                arrX(j) = arr(i, j)
            Next
            Array.Sort(arrX)
            For j = 0 To u2
                arrOut(i, j) = arrX(j)
            Next
        Next
        Return arrOut
    End Function



    Function tiqu_duoma_from_position(position As String, positionLength As Integer) As Integer(,)

        Dim arr(0 To general_Ubound, 0 To positionLength - 1) As Integer

        Select Case position
            Case "1,2,3"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 1)
                    arr(i, 2) = arrJH_sep_I(i, 2)
                Next
            Case "1,2,4"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 1)
                    arr(i, 2) = arrJH_sep_I(i, 3)
                Next
            Case "1,2,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 1)
                    arr(i, 2) = arrJH_sep_I(i, 4)
                Next
            Case "1,3,4"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                    arr(i, 2) = arrJH_sep_I(i, 3)
                Next
            Case "1,3,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                    arr(i, 2) = arrJH_sep_I(i, 4)
                Next
            Case "1,4,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                    arr(i, 2) = arrJH_sep_I(i, 4)
                Next
            Case "2,3,4"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                    arr(i, 2) = arrJH_sep_I(i, 3)
                Next
            Case "2,3,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                    arr(i, 2) = arrJH_sep_I(i, 4)
                Next
            Case "2,4,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                    arr(i, 2) = arrJH_sep_I(i, 4)
                Next
            Case "3,4,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 2)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                    arr(i, 2) = arrJH_sep_I(i, 4)
                Next
            Case "1,2"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 1)
                Next
            Case "1,3"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                Next
            Case "1,4"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                Next
            Case "1,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 4)
                Next
            Case "2,3"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                Next
            Case "2,4"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                Next
            Case "2,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 4)
                Next
            Case "3,4"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 2)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                Next
            Case "3,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 2)
                    arr(i, 1) = arrJH_sep_I(i, 4)
                Next
            Case "4,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 3)
                    arr(i, 1) = arrJH_sep_I(i, 4)
                Next
            Case "1,2,3,4"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                Next
            Case "1,2,3,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                    arr(i, 1) = arrJH_sep_I(i, 4)
                Next
            Case "1,2,4,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                    arr(i, 1) = arrJH_sep_I(i, 4)
                Next
            Case "1,3,4,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 0)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                    arr(i, 1) = arrJH_sep_I(i, 4)
                Next
            Case "2,3,4,5"
                For i = 0 To general_Ubound
                    arr(i, 0) = arrJH_sep_I(i, 1)
                    arr(i, 1) = arrJH_sep_I(i, 2)
                    arr(i, 1) = arrJH_sep_I(i, 3)
                    arr(i, 1) = arrJH_sep_I(i, 4)
                Next
        End Select
        Return arr
    End Function
End Module
